home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
lisp
/
eulisp
/
mpfeel.lha
/
MPFeel
/
Plurals
/
Modules
/
pp.em
< prev
next >
Wrap
Lisp/Scheme
|
1992-07-02
|
3KB
|
210 lines
(defmodule pp (standard0 ppl plural) ()
(format t "\nThis module has no plural space conservation tweaks!\n")
(setq global-field (make-paralation 512))
(setq base-context (car (contexts global-field)))
(setq base-offset (car (contexts global-field)))
(defun list-shift-distances (config)
(if (eq config 1) ()
(cons (/ config 2) (list-shift-distances (/ config 2)))))
(setq shifts (mapcar (lambda (n) (car (offsets (elwise ((i global-field))
(let ((get-from (+ i n)))
(if (< get-from 512)
(cons get-from ())
()))))))
(reverse (list-shift-distances 512))))
(defun ll-vref (context offset shifter combiner)
(let ((shifter (mp-assign context (mp-make-plural base-context) shifter))
(ofst-p (mp-assign context (mp-make-plural base-context) offset))
(data (mp-make-plural context))
(tive (mp-make-plural context)))
(mp-move base-context ofst-p context shifter data)
(mp-move base-context (mp-assign context (mp-make-plural base-context)
(mp-bang context t))
context shifter tive)
(mp-if context (mp-test context tive 2))
(mp-assign context tive (mp-car context tive))
(mp-if context tive)
;(format t "offset: ~a\n" (allocate-xec context offset))
;(format t "data (~a): ~a\n" data (allocate-xec context (mp-car context data)))
(mp-assign context offset (combiner offset (mp-car context data)))
;(format t "offset: ~a\n" (allocate-xec context offset))
(mp-fi context)
(mp-fi context)
offset))
(defun l-vref (context offset combiner)
(let ((offset (mp-assign context (mp-make-plural context) offset)))
(labels ((recurse (shifts)
(ll-vref context offset (car shifts) combiner)
(if (null (cdr shifts)) offset
(recurse (cdr shifts)))))
(recurse shifts)
(mp-ref context offset 0))))
(defun s-vref (l with)
(if (null (cdr l)) (car l)
(with (car l) (s-vref (cdr l) with))))
(defmacro vref (f with)
`(s-vref (mapcar (lambda (c o)
(Set-The-Context c)
(l-vref c o ,(rewire with)))
(contexts ,f) (offsets ,f)) ,with))
(defun ll-scan (context offset combiner)
(let ((offset (mp-assign context (mp-make-plural context) offset)))
(labels ((recurse (shifts)
(ll-vref context offset (car shifts) combiner)
(if (null (cdr shifts)) offset
(recurse (cdr shifts)))))
(recurse shifts)
offset)))
(defun l-scan (l with)
(if (null (cdr l)) l
(let ((rest (l-scan (cdr l) with)))
(cons (with (car l) (car rest)) rest))))
(defmacro scan (f with)
`(let* ((result (make-field (paralation ,f)
(mapcar mp-make-plural (contexts ,f))))
(tmp-pspace (mp-ps-ref)))
(mapcar (lambda (c o r)
(Set-The-Context c)
(mp-assign c r (ll-scan c o ,(rewire with))))
(contexts ,f) (offsets ,f) (offsets result))
(mapcar (lambda (v c o)
(Set-The-Context c)
(mp-assign c o (,(rewire with) o (mp-bang c v))))
(cdr (l-scan (mapcar (lambda (c o) (mp-ref c o 0))
(contexts ,f) (offsets result)) ,with))
(contexts ,f) (offsets result))
result))
(export scan vref s-vref l-vref ll-scan l-scan)
)